import { getGoodsCategory as getGoodsCategoryAPI } from '@/api/shop/goods.js'
const Menu = {
  // namespaced: true,
  state: {
    menuData: undefined
  },
  getters: {
    hasMenuData: state => {
      return state.menuData !== undefined
    }
  },
  mutations: {
    SET_MENU_DATA (state, data) {
      state.menuData = data
    }
  },
  actions: {
    getMenuData ({ commit, state }) {
      getGoodsCategoryAPI().then(res => {
        commit('SET_MENU_DATA', res.data)
      }).catch(() => {
        commit('SET_MENU_DATA', [
          { cname: '惠文创' },
          { cname: '惠旅游' },
          { cname: '惠教育' },
          { cname: '惠出版' },
          { cname: '惠演绎' },
          { cname: '惠赛事' },
          { cname: '惠艺术' },
          { cname: '惠文玩' },
          { cname: '惠阅读' },
          { cname: '惠休闲' },
          { cname: '惠康养' },
          { cname: '惠影视' },
          { cname: '惠动漫' },
          { cname: '惠网游' },
          { cname: '惠市集' }
        ])
      })
    }
  }
}
export default Menu
